//
//  BasicViewController.m
//  ShoppingExperience
//
//  Created by LiYinDi on 14-12-29.
//  Copyright (c) 2014年 RuiBen. All rights reserved.
//

#import "BasicViewController.h"
#import "HomeViewController.h"
#import "HomeBasicViewController.h"
#import "ShopGuideViewController.h"
#import "StockViewController.h"
#import "ProductViewController.h"
#import "FactoryViewController.h"
#import "ScanViewController.h"
#import "ViewController3.h"
#import "ViewController4.h"
#import "ShopAffairViewController.h"
//shopGuide
#import "MemberViewController.h"

#import "ShopCartViewController.h"
#import "OrderViewController.h"
#import "DepositViewController.h"
#import "ServiceViewController.h"
#import "ReturnAndChangeViewController.h"

//Product
#import "ProductHomeViewController.h"
#import "Product_SeriesViewController.h"
//#import "Product_HuangJinViewController.h"
//#import "Product_BoJinViewController.h"
//#import "Product_KJinViewController.h"
//#import "Product_ZuanShiViewController.h"
//#import "Product_feiCuiViewController.h"
//#import "Product_CaiBaoViewController.h"
//#import "Product_ZhenZhuViewController.h"
//#import "Product_YinShiViewController.h"
//#import "Product_OtherViewController.h"
#import "ProductItemDetailViewController.h"
//#import "SeriesViewController.h"
//#import "SeriesDetailViewController.h"
//#import "StyleDetailViewController.h"

//Data
//#import "DataSliderViewController.h"
//#import "NewMemberThisMonthViewController.h"
//#import "OrdersThisMonthViewController.h"
//#import "ServiceRecordThisMonthViewController.h"
//#import "ReturnRecordThisMonthViewController.h"
//#import "Stock1ViewController.h"
//#import "MemberDetailViewController.h"
//#import "OrderDetailViewController.h"
//#import "ServiceDetailViewController.h"
//#import "ReturnDetailViewController.h"
//#import "StockDetailViewController.h"

//ShopAffair
//#import "StoreCenterViewController.h"
//#import "GuideManagementViewController.h"
//#import "SampleDisplayViewController.h"
//#import "AddGuideViewController.h"
//#import "PurchaseManagementViewController.h"
//#import "ArrivalManagementViewController.h"
//#import "ReturnsManagementViewController.h"
//#import "InventoryManagementViewController.h"

//stock
#import "StockInquiryViewController.h"
#import "ProductDisplayViewController.h"
#import "AllocateLibraryViewController.h"
#import "ManagerGoodViewController.h"
#import "ArrivalGoodViewController.h"
#import "InventoryManageViewController.h"
#import "OldGoldManageViewController.h"
//shopAffair
#import "AccountCenterViewController.h"

//Scan
#import "ScanViewController.h"
#import "ScanHomeViewController.h"
#import "ScanShopViewController.h"
#import "ScanStockViewController.h"
#import "ScanMemberViewController.h"

//factory
//#import "FactorySliderViewController.h"
#import "FactoryDynamicDetailViewController.h"
#import "FactoryActivityDetailViewController.h"
#import "FactoryTrainDetailViewController.h"
#import "FactoryNewProductViewController.h"
@interface BasicViewController ()<ShopCartDelegate,HomeViewControllerDelegate,Product_SeriesDelegate, ProductItemDetailDelegate,StockInquiryDelegate,ProductHomeDelegate,OrderDelegate,ScanHomeDelegate,ScanStockDelegate,ScanShopDelegate,ScanMemberDelegate,NewProductDelegate,AllocateLibraryDelegate,ArrivalGoodDelegate,InventoryManageDelegate,ProductDisplayDelegate,ReturnDelegate,ServiceDelegate>
{
    
    NSArray* viewControllers;
    HomeBasicViewController *homeBasicVC;
    HomeViewController *homeVC;
    
    ShopGuideViewController *guideVC;
    ProductViewController *productVC;
    StockViewController *stockVC;
    
    MemberViewController *memberVC;
    ShopCartViewController *shopCartVC;
    
    ScanViewController *scanVC;
   
   // OrderDetailViewController *orderDetailVC;
//    ReturnDetailViewController *returnDetailVC;
//    ServiceDetailViewController *serviceDetailVC;
    
    ReturnAndChangeViewController *returnAndChangeVC;
    ProductDisplayViewController *productDisplayVC;
    AllocateLibraryViewController *allocateLibraryVC;
    ArrivalGoodViewController *arrivalVC;
    Product_SeriesViewController *seriesVC;
    ProductItemDetailViewController *itemDetailVC;
    
    ScanShopViewController *scanShopVC;
    ScanStockViewController *scanStockVC;
    ScanMemberViewController *scanMemberVC;
    ScanHomeViewController *scanHomeVC;
    //shopGuide
    ServiceViewController *serviceVC;
    OrderViewController *orderVC;
    DepositViewController *depositVC;
    
    //stock
    InventoryManageViewController *inventoryVC;
    
    //factory
    FactoryViewController *factoryVC;
    FactoryDynamicDetailViewController *factoryDynamicDetailVC;
    FactoryActivityDetailViewController *factoryActivityDetailVC;
    
    //My
    AccountCenterViewController *accountCenterVC;
}

@end

@implementation BasicViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization

    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.delegate = self;
    NSMutableArray* controllersToAdd = [[NSMutableArray alloc] init];
     homeBasicVC=[[HomeBasicViewController alloc] init];
   // HomeViewController *homeVC=[[HomeViewController alloc] init];
  //  [controllersToAdd addObject:homeVC];
     [controllersToAdd addObject:homeBasicVC];
    
    productVC=[[ProductViewController alloc] init];
    [controllersToAdd addObject:productVC];
    
    guideVC=[[ShopGuideViewController alloc] init];
    [controllersToAdd addObject:guideVC];

    
    stockVC=[[StockViewController alloc] init];
    [controllersToAdd addObject:stockVC];
    
    factoryVC=[[FactoryViewController alloc] init];
    [controllersToAdd addObject:factoryVC];
    
    ViewController3 *vc3=[[ViewController3 alloc] init];
    [controllersToAdd addObject:vc3];
    
    scanVC=[[ScanViewController alloc] init];
    [controllersToAdd addObject:scanVC];
    
    ViewController4 *vc4=[[ViewController4 alloc] init];
    [controllersToAdd addObject: vc4];
    
    ShopAffairViewController *shopAffairVC=[[ShopAffairViewController alloc] init];
    [controllersToAdd addObject:shopAffairVC];
   /// [guideVC setDdddd:4444];
    
    viewControllers=[NSArray arrayWithArray:controllersToAdd];
    [self setViewControllers:viewControllers];
    self.selectedViewController = ((UIViewController*)[viewControllers objectAtIndex:0]);
    [self.view sendSubviewToBack:homeBasicVC.view];
    
    shopCartVC=[[ShopCartViewController alloc] init];
    shopCartVC.delegate=self;
    orderVC=[[OrderViewController alloc] init];
    orderVC.delegate=self;
    //shopAffair
     NSMutableArray *addShopAffairControllers=[[NSMutableArray alloc] init];
    accountCenterVC=[[AccountCenterViewController alloc] init];
    [addShopAffairControllers addObject:accountCenterVC];//0
    NSArray *shopAffairArray=[NSArray arrayWithArray:addShopAffairControllers];
    [shopAffairVC setShopAffairViewControllers:shopAffairArray];

   
    //Product
    NSMutableArray *addProductControllers=[[NSMutableArray alloc] init];
    
    ProductHomeViewController *productHomeVc=[[ProductHomeViewController alloc] init];
    productHomeVc.delegate=self;
    [addProductControllers addObject:productHomeVc];//0
    
    seriesVC=[[Product_SeriesViewController alloc] init];
    seriesVC.delegate=self;
    [addProductControllers addObject:seriesVC];//1
    
    itemDetailVC=[[ProductItemDetailViewController alloc] init];
    itemDetailVC.delegate=self;
    [addProductControllers addObject:itemDetailVC];//2
    [addProductControllers addObject: shopCartVC];//3
    [addProductControllers addObject: orderVC];//4
    NSArray *productArray=[NSArray arrayWithArray:addProductControllers];
    [productVC setProductViewControllers:productArray];
    //shopguide
    NSMutableArray *addShopGuideControllers=[[NSMutableArray alloc] init];
    memberVC=[[MemberViewController alloc] init];
    [addShopGuideControllers addObject:memberVC];//0
    
//    scanBarCodeVC=[[ScanBarCodeViewController alloc] init];
//    scanBarCodeVC.delegate=self;
//    [addShopGuideControllers addObject:scanBarCodeVC];//1
     depositVC=[[DepositViewController alloc] init];
    
    [addShopGuideControllers addObject:shopCartVC]; //2
    
   
    [addShopGuideControllers addObject:orderVC];//3
    [addShopGuideControllers addObject:depositVC];//4
    
    serviceVC=[[ServiceViewController alloc] init];
    serviceVC.delegate=self;
    [addShopGuideControllers addObject:serviceVC];//5
    
    returnAndChangeVC=[[ReturnAndChangeViewController alloc] init];
    returnAndChangeVC.delegate=self;
    [addShopGuideControllers addObject:returnAndChangeVC];//5
    //[addShopGuideControllers addObject:itemDetailVC];//6
    
    
    NSArray *shopGuideArray=[NSArray arrayWithArray:addShopGuideControllers];
    [guideVC setShopGuideViewControllers:shopGuideArray];
    
    //stock
     NSMutableArray *addStockControllers=[[NSMutableArray alloc] init];
    StockInquiryViewController *stockInquiryVC=[[StockInquiryViewController alloc] init];
    stockInquiryVC.delegate=self;
    [addStockControllers addObject:stockInquiryVC];
    productDisplayVC=[[ProductDisplayViewController alloc] init];
    productDisplayVC.delegate=self;
    [addStockControllers addObject:productDisplayVC];
     allocateLibraryVC=[[AllocateLibraryViewController alloc] init];
     allocateLibraryVC.delegate=self;
    [addStockControllers addObject:allocateLibraryVC];
//    ManagerGoodViewController *managerVC=[[ManagerGoodViewController alloc] init];
//    [addStockControllers addObject:managerVC];
    arrivalVC=[[ArrivalGoodViewController alloc] init];
    arrivalVC.delegate=self;
    [addStockControllers addObject:arrivalVC];
    inventoryVC=[[InventoryManageViewController alloc] init];
    inventoryVC.delegate=self;
   [addStockControllers addObject:inventoryVC];
//     SubstituteManageViewController *substituteVC=[[SubstituteManageViewController alloc] init];
//    [addStockControllers addObject:substituteVC];
    
    OldGoldManageViewController *oldManageVC=[[OldGoldManageViewController alloc] init];
    [addStockControllers addObject:oldManageVC];
   
   

    NSArray *stockArray=[NSArray arrayWithArray:addStockControllers];
    [stockVC setShopAffairViewControllers:stockArray];
    
    //Analysis
    NSMutableArray *addScanControllers=[[NSMutableArray alloc] init];
    scanHomeVC=[[ScanHomeViewController alloc] init];
    scanHomeVC.delegate=self;
    [addScanControllers addObject:scanHomeVC];
    
    //scanShopVC=[[ScanShopViewController alloc] init];
   // scanShopVC.delegate=self;
    [addScanControllers addObject:itemDetailVC];
    
    scanStockVC=[[ScanStockViewController alloc] init];
    scanStockVC.delegate=self;
    [addScanControllers addObject:scanStockVC];
    
    scanMemberVC=[[ScanMemberViewController alloc] init];
    scanMemberVC.delegate=self;
    [addScanControllers addObject:scanMemberVC];
    
    [addScanControllers addObject:shopCartVC];
    
    NSArray *scanArray=[NSArray arrayWithArray:addScanControllers];
    [scanVC setScanViewControllers:scanArray];
    
    //factory
    NSMutableArray *addFactoryControllers=[[NSMutableArray alloc] init];
  //  FactorySliderViewController *factorySliderVC=[[FactorySliderViewController alloc] init];
   // factorySliderVC.delegate=self;
   // [addFactoryControllers addObject:factorySliderVC];
    
   // factoryDynamicDetailVC=[[FactoryDynamicDetailViewController alloc] init];
  //  factoryDynamicDetailVC.delegate=self;
  //  [addFactoryControllers addObject:factoryDynamicDetailVC];
    
   // factoryActivityDetailVC=[[FactoryActivityDetailViewController alloc] init];
   // factoryActivityDetailVC.delegate=self;
   // [addFactoryControllers addObject:factoryActivityDetailVC];
    
  //  FactoryTrainDetailViewController *factoryTrainDetailVC=[[FactoryTrainDetailViewController alloc] init];
   // factoryTrainDetailVC.delegate=self;
   // [addFactoryControllers addObject:factoryTrainDetailVC];
    
    FactoryNewProductViewController *newProductVC=[[FactoryNewProductViewController alloc] init];
    newProductVC.delegate=self;
    [addFactoryControllers addObject:newProductVC];
    [addFactoryControllers addObject:itemDetailVC];
    
    NSArray *factoryArray=[NSArray arrayWithArray:addFactoryControllers];
    [factoryVC setFactoryViewControllers:factoryArray];
    
    //Home
    NSMutableArray *addHomeBasicControllers=[[NSMutableArray alloc] init];
    homeVC=[[HomeViewController alloc] init];
    homeVC.delegate=self;
    [addHomeBasicControllers addObject:homeVC];
    [addHomeBasicControllers addObject:memberVC];
    [addHomeBasicControllers addObject:shopCartVC];
    [addHomeBasicControllers addObject:orderVC];
    [addHomeBasicControllers addObject:stockInquiryVC];
    [addHomeBasicControllers addObject:serviceVC];
    [addHomeBasicControllers addObject:productDisplayVC];
    [addHomeBasicControllers addObject:returnAndChangeVC];
  
       [addHomeBasicControllers addObject:arrivalVC];
  //  [addHomeBasicControllers addObject:managerVC];
    //[addHomeBasicControllers addObject:inventoryVC];
    
    NSArray *homeBasicArray=[NSArray arrayWithArray:addHomeBasicControllers];
    [homeBasicVC setHomeViewControllers:homeBasicArray];
    // Do any additional setup after loading the view from its nib.
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillShow:)
                                                 name:UIKeyboardWillShowNotification
                                               object:nil];
}
- (void)keyboardWillShow:(NSNotification *)aNotification
{
    //获取键盘的高度
    NSDictionary *userInfo = [aNotification userInfo];
    NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
    CGRect keyboardRect = [aValue CGRectValue];
    CGFloat height = keyboardRect.size.height;
   
    [Global setKeyboardHeight:height];
    
   // [[NSNotificationCenter defaultCenter] removeObserver:self];
}
#pragma mark productHomeDelegate Method
-(void)productHomeButtonClick:(NSString *)codeStr selectTypeID:(NSUInteger)selectTypeID
{
   

    seriesVC.typeCodeStr=codeStr;
    seriesVC.selectID=selectTypeID;
  //  [productVC productHomeBtnClick];
    [Global setProductID:1];
   
   [self setSelectedIndex:1];
    
}
#pragma mark product_SeriesDelegate Method
-(void)rightTableView:(NSUInteger)index code:(NSString *)itemCode _itemCodeArray:(NSMutableArray *)_itemCodeArray _itemNameArray:(NSMutableArray *)_itemNameArray _itemWhereArray:(NSMutableArray *)_itemWhereArray _itemPriceArray:(NSMutableArray *)_itemPriceArray _itemUrlArray:(NSMutableArray *)_itemUrlArray _itemWeightArray:(NSMutableArray *)_itemWeightArray   _itemSeriesNameArray:(NSMutableArray *)_itemSeriesNameArray _itemTypeNameArray:(NSMutableArray *)_itemTypeNameArray _itemInDateArray:(NSMutableArray *)_itemInDateArray
{
    itemDetailVC.itemCodeArray=[NSMutableArray arrayWithArray:_itemCodeArray];
    itemDetailVC.itemNameArray=[NSMutableArray arrayWithArray:_itemNameArray];
    itemDetailVC.itemPriceArray=[NSMutableArray arrayWithArray:_itemPriceArray];
    itemDetailVC.itemUrlArray=[NSMutableArray arrayWithArray:_itemUrlArray];
    itemDetailVC.itemWeightArray=[NSMutableArray arrayWithArray:_itemWeightArray];
    itemDetailVC.itemWhereArray=[NSMutableArray arrayWithArray:_itemWhereArray];
    itemDetailVC.itemSeriesNameArray=[NSMutableArray arrayWithArray:_itemSeriesNameArray];
    itemDetailVC.itemInDateArray=[NSMutableArray arrayWithArray:_itemInDateArray];
    itemDetailVC.itemTypeNameArray=[NSMutableArray arrayWithArray:_itemTypeNameArray];
    
    itemDetailVC.itemCodeStr=itemCode;
    itemDetailVC.selectID=index;
    [Global setHomeCustomID:20];
    [Global setProductID:2];
    [self setSelectedIndex:1];
   // [productVC productSeriesCellClick];
}
#pragma mark factoryNewProductDelegate Method
//-(void)factoryNewProductRightTableView:(NSUInteger)index code:(NSString *)itemCode  companyCodeStr:(NSString *)companyCodeStr _itemCodeArray:(NSMutableArray *)_itemCodeArray _itemNameArray:(NSMutableArray *)_itemNameArray _itemWhereArray:(NSMutableArray *)_itemWhereArray _itemPriceArray:(NSMutableArray *)_itemPriceArray _itemUrlArray:(NSMutableArray *)_itemUrlArray _itemWeightArray:(NSMutableArray *)_itemWeightArray   _itemSeriesNameArray:(NSMutableArray *)_itemSeriesNameArray _itemTypeNameArray:(NSMutableArray *)_itemTypeNameArray _itemInDateArray:(NSMutableArray *)_itemInDateArray
//
//{
//   // NSLog(@"ddddddddd22222");
//    itemDetailVC.itemCodeArray=[NSMutableArray arrayWithArray:_itemCodeArray];
//    itemDetailVC.itemNameArray=[NSMutableArray arrayWithArray:_itemNameArray];
//    itemDetailVC.itemPriceArray=[NSMutableArray arrayWithArray:_itemPriceArray];
//    itemDetailVC.itemUrlArray=[NSMutableArray arrayWithArray:_itemUrlArray];
//    itemDetailVC.itemWeightArray=[NSMutableArray arrayWithArray:_itemWeightArray];
//    itemDetailVC.itemWhereArray=[NSMutableArray arrayWithArray:_itemWhereArray];
//    itemDetailVC.itemSeriesNameArray=[NSMutableArray arrayWithArray:_itemSeriesNameArray];
//    itemDetailVC.itemInDateArray=[NSMutableArray arrayWithArray:_itemInDateArray];
//    itemDetailVC.itemTypeNameArray=[NSMutableArray arrayWithArray:_itemTypeNameArray];
//    itemDetailVC.companyCodeStr=companyCodeStr;
//    itemDetailVC.itemCodeStr=itemCode;
//    itemDetailVC.selectID=index;
//    [factoryVC factoryNewProductRightCellClick];
//}

#pragma mark factoryNewProductDelegate Method
-(void)newProductRightTableView:(NSUInteger)index code:(NSString *)itemCode companyCodeStr:(NSString *)companyCodeStr  _itemCodeArray:(NSMutableArray *)_itemCodeArray _itemNameArray:(NSMutableArray *)_itemNameArray _itemWhereArray:(NSMutableArray *)_itemWhereArray _itemPriceArray:(NSMutableArray *)_itemPriceArray _itemUrlArray:(NSMutableArray *)_itemUrlArray _itemWeightArray:(NSMutableArray *)_itemWeightArray   _itemSeriesNameArray:(NSMutableArray *)_itemSeriesNameArray _itemTypeNameArray:(NSMutableArray *)_itemTypeNameArray _itemInDateArray:(NSMutableArray *)_itemInDateArray
{
   
    itemDetailVC.itemCodeArray=[NSMutableArray arrayWithArray:_itemCodeArray];
    itemDetailVC.itemNameArray=[NSMutableArray arrayWithArray:_itemNameArray];
    itemDetailVC.itemPriceArray=[NSMutableArray arrayWithArray:_itemPriceArray];
    itemDetailVC.itemUrlArray=[NSMutableArray arrayWithArray:_itemUrlArray];
    itemDetailVC.itemWeightArray=[NSMutableArray arrayWithArray:_itemWeightArray];
    itemDetailVC.itemWhereArray=[NSMutableArray arrayWithArray:_itemWhereArray];
    itemDetailVC.itemSeriesNameArray=[NSMutableArray arrayWithArray:_itemSeriesNameArray];
    itemDetailVC.itemInDateArray=[NSMutableArray arrayWithArray:_itemInDateArray];
    itemDetailVC.itemTypeNameArray=[NSMutableArray arrayWithArray:_itemTypeNameArray];
    itemDetailVC.companyCodeStr=companyCodeStr;
    itemDetailVC.itemCodeStr=itemCode;
    itemDetailVC.selectID=index;
    [factoryVC factoryNewProductRightCellClick];

}
-(void)product_SeriesBackClick
{
    [productVC productSeriesBackClick];
}
-(void)product_SeriesShopCartClick
{
    shopCartVC.productOrDetailStr=@"PRODUCT";
    [Global setShopGuideID:1];
    [self setSelectedIndex:2];
    
    
   // [productVC addToShopCart];
}
#pragma mark productItemDetailDelegate Method
-(void)productItemDetailShopCartClick
{
   // NSLog(@"[Global getShopCartID]====%d",[Global getShopCartID]);
//    if ([Global getScanID]==2) {
//        
//   
//     [productVC addToShopCart];
//    }
//    else if ([Global getScanID]==1)
//    {
//        [scanVC scanShopShopCartClick];
//    }
    shopCartVC.productOrDetailStr=@"DETAIL";
    [Global setShopGuideID:1];
    [self setSelectedIndex:2];
    

}
-(void)productItemDetailBackClick
{
    if ([Global getHomeCustomID]==20||[Global getHomeCustomID]==1) {
    [productVC productItemDetailBackBtnClick];
    }
    else if ([Global getHomeCustomID]==10)
    {
        if (scanHomeVC.timer!=nil) {
            [scanHomeVC.timer invalidate];
            scanHomeVC.timer=nil;
        }
        if (scanHomeVC.captureSession!=nil) {
            
            
            [scanHomeVC.captureSession stopRunning];
            scanHomeVC.captureSession = nil;
        }
        if (scanHomeVC.videoPreviewLayer !=nil) {
            
            
            [scanHomeVC.videoPreviewLayer removeFromSuperlayer];
        }
        
       

        //[Global setShopGuideID:1];
        self.cellID=6;
        [self setSelectedIndex:6];
       // [scanVC productItemDetailBackBtnClick];
    }
    else if ([Global getHomeCustomID]==35)
    {
        [factoryVC factoryNewProductDetailBackClick];
    }
}
#pragma mark orderDelegate Method
-(void)orderBackClick
{
    [productVC orderBackClick];
}
-(void)OrderShopCtarClick
{
    shopCartVC.productOrDetailStr=@"";
    [Global setShopGuideID:1];
    [self setSelectedIndex:2];
}
#pragma mark AllocateLibraryDelegate Method
-(void)AllocateLibraryShopCtarClick
{
    shopCartVC.productOrDetailStr=@"";
    [Global setShopGuideID:1];
    [self setSelectedIndex:2];
}
#pragma mark ArrivalGoodDelegate Method
-(void)ArrivalGoodShopCtarClick
{
    shopCartVC.productOrDetailStr=@"";
    [Global setShopGuideID:1];
    [self setSelectedIndex:2];
}
#pragma mark InventoryManageDelegate Method
-(void)InventoryManageShopCtarClick
{
    shopCartVC.productOrDetailStr=@"";
    [Global setShopGuideID:1];
    [self setSelectedIndex:2];
}
#pragma mark ProductDisplayDelegate Method
-(void)ProductDisplayShopCtarClick
{
    shopCartVC.productOrDetailStr=@"";
    [Global setShopGuideID:1];
    [self setSelectedIndex:2];
}
#pragma mark ServiceDelegate Method
-(void)ServiceShopCtarClick
{
    shopCartVC.productOrDetailStr=@"";
    [Global setShopGuideID:1];
    [self setSelectedIndex:2];
}
#pragma mark ReturnDelegate Method
-(void)ReturnShopCtarClick
{
    shopCartVC.productOrDetailStr=@"";
    [Global setShopGuideID:1];
    [self setSelectedIndex:2];
}
//pragma mark scanItemDetailDelegate Method
-(void)scanItemDetailShopCartClick
{
    [guideVC addToShopCartClick];
}
//pragma mark sampleDisplayDelegate Method
#pragma mark sampleDisplayDelegate Method
-(void)sampleDisplayBackClick
{
    [homeBasicVC signInBackBtnClick];
}
#pragma mark StockInquiryDelegate Method
-(void)stockInquiryShopCartClick
{
    //[stockVC addToShopCart];
    shopCartVC.productOrDetailStr=@"";
    [Global setShopGuideID:1];
    [self setSelectedIndex:2];
}
#pragma mark DirectCashierDelegate Method
-(void)directCashierBackClick
{
    [homeBasicVC signInBackBtnClick];
}
#pragma mark ShopCartDelegate Method
-(void)shopcartCashierFinish
{

//    if([Global getShopCartID]==1)
//    {
//        if ([[Global getIsHZ]isEqualToString:@"HZ"]) {
//            
   // NSLog(@"eeeeeeee21231414");
     [Global setShopGuideID:2];
    [self setSelectedIndex:2];
   
//        }
//    //[guideVC shopcartCashierFinish];
//    }
//    else if ([Global getShopCartID]==2||[Global getShopCartID]==3)
//    {
//        [self setSelectedIndex:1];
//        [Global setShopGuideID:2];
//      //  [productVC shopcartCashierFinish];
//    }
}
-(void)shopCartBackClick
{
    if ([shopCartVC.productOrDetailStr isEqualToString:@"DETAIL"])
    {
        [Global setProductID:2];
        [self setSelectedIndex:1];
//        [productVC detailShopCartBackClick];
    }
    else if ([shopCartVC.productOrDetailStr isEqualToString:@"PRODUCT"])
    {
        [Global setProductID:1];
        
        [self setSelectedIndex:1];
        //[productVC productShopCartBackClick];
    }
//   if ([Global getScanID]==1)
//    {
//      //  NSLog(@"[Global getScanID]==%d",[Global getScanID]);
//        [guideVC shopCartBackClick];
//    }
    if ([Global getScanID]==1) {
        [scanVC scanShopShopCartBackClick];
    }

}
//#pragma mark SignInViewController Delegate Method
//-(void)signInBackClick
//{
//    [homeBasicVC signInBackBtnClick];
//}
#pragma mark HomeViewController Delegate Method
-(void)customBtnClick:(NSInteger)index
{
  //  NSLog(@"index1111====%d",index);
    [homeBasicVC customItemClick:index];
}
#pragma mark ScanBarCodeViewController Delegate Method
-(void)scanResult:(NSString *)codeStr
{
    if ([Global getHomeCustomID]==0) {
      //   styleDetailVC.itemCodeStr=@"S000100001";
        [homeBasicVC scanResult];
    }
    else
    {
   
    itemDetailVC.itemCodeStr=codeStr;
   // styleDetailVC.itemCodeStr=@"S000100001";
    [guideVC scanResult];
    }
}
#pragma mark ScanMemberViewController Delegate Method
-(void)scanMemberBackClick
{
    [scanVC scanMemberBack];
}
#pragma mark ScanShopViewController Delegate Method
//-(void)scanShopBackClick
//{
//    [scanVC scanShopBack];
//}
-(void)scanShopShopCartClick
{
    [scanVC scanShopShopCartClick];
}
#pragma mark ScanStockViewController Delegate Method
-(void)scanStockBackClick
{
    if (scanHomeVC.timer!=nil) {
        [scanHomeVC.timer invalidate];
        scanHomeVC.timer=nil;
    }
    if (scanHomeVC.captureSession!=nil) {
        
        
        [scanHomeVC.captureSession stopRunning];
        scanHomeVC.captureSession = nil;
    }
    if (scanHomeVC.videoPreviewLayer !=nil) {
        
        
        [scanHomeVC.videoPreviewLayer removeFromSuperlayer];
    }

    scanHomeVC.scanTypeStr=@"SCANSTOCK";
    [scanVC scanStockBack];
}
//-(void)scanStockSuccess
//{
//    scanHomeVC.scanTypeStr=@"SCANSHOP";
//    [scanHomeVC.stockItemCodeArray removeAllObjects];
//    [scanHomeVC.stockItemNameArray removeAllObjects];
//    [scanHomeVC.stockItemPriceArray removeAllObjects];
//    [scanHomeVC.stockItemUrlArray removeAllObjects];
//    [scanHomeVC.stockItemWeightArray removeAllObjects];
//    [scanHomeVC.stockItemWhereArray removeAllObjects];
//    [scanHomeVC.stockItemSeriesNameArray removeAllObjects];
//    [scanHomeVC.stockItemInDateArray removeAllObjects];
//    [scanHomeVC.stockItemTypeNameArray removeAllObjects];
//    [scanHomeVC.stockNotExistArray removeAllObjects];
//    [scanHomeVC.stockResultArray removeAllObjects];
//}
#pragma mark ScanHomeViewController Delegate Method
-(void)scanHomeShopResult:(NSString *)codeStr
{
   // NSLog(@"codeStr=====%@",codeStr);
   itemDetailVC.itemCodeStr=codeStr;
   // [scanVC scanShop];
    [Global setHomeCustomID:10];
    [Global setProductID:2];
    [self setSelectedIndex:1];
    [self setCellID:1];
}
-(void)scanHomeMemberResult:(NSString *)codeStr
{
    // NSLog(@"codeStr=====%@",codeStr);
    scanMemberVC.memberCodeStr=codeStr;
    [scanVC scanMember];
}

-(void)scanHomeStockResult
{

    [scanVC scanStock];
}

-(void)scanCancelClick
{
    if ([Global getHomeCustomID]==0) {
    
    [homeBasicVC signInBackBtnClick];
    }
}
#pragma mark ScanProductDetailViewController Delegate Method
//-(void)addToShopCartClick
//{
//    [guideVC addToShopCartClick];
//}
//#pragma mark SeriesViewController Delegate Method
//-(void)seriesCellClick:(NSUInteger)index code:(NSString *)SeriesCode
//{
//    seriesDetailVC.seriesCodeStr=SeriesCode;
//    [productVC seriesCellClick:index];
//}
//#pragma mark SeriesDetailViewController Delegate Method
//-(void)seriesDetailCellClick:(NSUInteger)index code:(NSString *)itemCode
//{
//   styleDetailVC.itemCodeStr=itemCode;
//    [productVC seriesDetailCellClick:index];
//}
//-(void)seriesDetailShopCartBtnClick
//{
//    [productVC ShopCartBtnClick];
//}
//-(void)seriesDetailBackClick
//{
//    //if([ Global getStyleDetailID]==1)
//   // {
//    [productVC seriesDetailBackClick];
////    }
////    else
////    {
////        [guideVC styleDetailBackClick];
////    }
//}
//#pragma mark StyleDetail Delegate Method
//-(void)addToShopCart
//{
//    if([Global getHomeCustomID]==0)
//    {
//        [homeBasicVC addToShopCartClick];
//    }
//    else
//    {
//    if ([ Global getStyleDetailID]==1) {
//        [productVC addToShopCart];
//    }
//    else
//    {
//     [guideVC addToShopCartClick];
//    }
//    }
//}
//-(void)styleDetailShopCartClick
//{
//    if ([ Global getStyleDetailID]==1) {
//        [productVC ShopCartBtnClick];
//    }
//    else
//    {
//        [guideVC directShopCartBtnClick];
//    }
//    
//}
//-(void)buyNowClick
//{
//    if ([Global getHomeCustomID]==0) {
//        [homeBasicVC buyNowClick];
//    }
//    else
//    {
//        
//     if ([ Global getStyleDetailID]==1) {
//    [productVC buyNowClick];
//     }
//    else
//    {
//        [guideVC buyNowClick];
//    }
//    }
//}
//-(void)styleDetailBackClick
//{
//    if ([Global getHomeCustomID]==0) {
//        [homeBasicVC styleDetailBackClick];
//    }
//    else
//    {
//  
//    if([ Global getStyleDetailID]==1)
//    {
//        [productVC styleDetailBackClick];
//    }
//    else
//    {
//        [guideVC styleDetailBackClick];
//    }
//    }
//}
//#pragma mark ShopCart Delegate Method
//-(void)shopCartBackClick
//{
//    if ([Global getHomeCustomID]==0) {
//        [homeBasicVC shopCartBackClick];
//    }
//    else
//    {
//    if ([Global getShopCartID]==1) {
//        [guideVC shopCartBackClick];
//    }
//    else if ([Global getShopCartID]==3)
//    {
//        [productVC shopCartBackClick];
//    }
//  }
//}
//-(void)shopCartCashierClick
//{
//    if ([Global getHomeCustomID]==0) {
//        [homeBasicVC shopCartCashierBtnClick];
//    }
//    else
//    {
//    if ([Global getShopCartID]==1) {
//        [guideVC shopCartCashierBtnClick];
//    }
//    else if ([Global getShopCartID]==3)
//    {
//        [productVC shopCartCashierBtnClick];
//    }
//  }
//
//}
//-(void)shopCartHomeClick
//{
//    if ([Global getHomeCustomID]==0) {
//        [homeBasicVC shopCartHomeBtnClick];
//    }
//    else
//    {
//    if ([Global getShopCartID]==1) {
//        [guideVC shopCartHomeBtnClick];
//    }
//    else if ([Global getShopCartID]==3)
//    {
//        [productVC shopCartHomeBtnClick];
//    }
//    }
//}
//-(void)videoBtnSelected:(NSUInteger)index
//{
//    [factoryVC videoBtnSelected:index];
//}
//#pragma FactoryDynamicDetailDelegate Method
//-(void)factoryDynamicDetailBack
//{
//    [factoryVC factoryDynamicDetailBackClick];
//}
//-(void)factoryActivityCellSelected:(NSString *)codeStr
//{
//    [factoryActivityDetailVC setActCodeString:codeStr];
//    [factoryVC factoryActivityCellClick:codeStr];
//}
//#pragma mark FactoryActivityDetailDelegate
//-(void)factoryActivityDetailBackClick
//{
//   
//    [factoryVC factoryDynamicDetailBackClick];
//}
//#pragma mark FactoryTrainDetailDelegate
//-(void)factoryTrainDetailBackClick
//{
//    
//    [factoryVC factoryTrainDetailBackClick];
//}
#pragma mark CashierViewController Method
-(void)cashierBackClick
{
    if ([Global getHomeCustomID]==0) {
        [homeBasicVC cashierBackClick];
    }
    else
    {
//    if ([Global getShopCartID]==1) {
//        [guideVC cashierBackClick];
//    }
     if ([Global getShopCartID]==3)
    {
        [productVC cashierBackBtnClick];
    }
    }
}
#pragma mark ConfirmDeliveryAddress Method
-(void)confirmAddressBackClick
{
    if([Global getHomeCustomID]==0)
    {
        [homeBasicVC confirmDeliveryAddressBtnClick];
    }
//    else
//    {
//    if ([Global getShopCartID]==1) {
//        [guideVC confirmDeliveryAddressBtnClick];
//    }
     if ([Global getShopCartID]==3)
    {
        [productVC confirmDeliveryAddressBtnClick];
    }
   // }
}
-(BOOL)tabBarController:(FSVerticalTabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
    [HttpRequest cancelRequest];
    [Global hideTextHudSub];
    orderVC.isLoad=@"N";
    serviceVC.isLoad=@"N";
    depositVC.isLoad=@"N";
    returnAndChangeVC.isLoad=@"N";
    productDisplayVC.isLoad=@"N";
    allocateLibraryVC.isLoad=@"N";
    arrivalVC.isLoad=@"N";
    inventoryVC.isLoad=@"N";
    accountCenterVC.isLoad=@"N";
    shopCartVC.isLoad=@"Y";
    shopCartVC.productOrDetailStr=@"";
    if (homeVC.barCodeTimer!=nil) {
        [homeVC.barCodeTimer invalidate];
        homeVC.barCodeTimer=nil;
    }
    if (homeVC.priceTimer!=nil) {
        [homeVC.priceTimer invalidate];
        homeVC.priceTimer=nil;
    }
     if ([viewControllers indexOfObject:viewController] ==0|| ([viewControllers indexOfObject:viewController] ==1)||  ([viewControllers indexOfObject:viewController] ==8)   )
     {
         if (scanHomeVC.timer!=nil) {
             [scanHomeVC.timer invalidate];
             scanHomeVC.timer=nil;
         }
         if (scanHomeVC.captureSession!=nil) {
             
             
             [scanHomeVC.captureSession stopRunning];
             scanHomeVC.captureSession = nil;
         }
         if (scanHomeVC.videoPreviewLayer !=nil) {
             
             
             [scanHomeVC.videoPreviewLayer removeFromSuperlayer];
         }
         

     }
    if ([viewControllers indexOfObject:viewController] ==6) {
        
              scanHomeVC.scanTypeStr=@"SCANSHOP";
    
    }
    
    if (accountCenterVC.barCodeTimer!=nil) {
        [accountCenterVC.barCodeTimer invalidate];
        accountCenterVC.barCodeTimer=nil;

    }
       
    if (shopCartVC.timer!=nil) {
        [shopCartVC.timer invalidate];
        shopCartVC.timer=nil;
        
    }
    
    if (serviceVC.timer!=nil) {
        [serviceVC.timer invalidate];
        serviceVC.timer=nil;
        
    }
    if (orderVC.timer!=nil) {
        [orderVC.timer invalidate];
        orderVC.timer=nil;
    }

    if ([Global getLoginToken].length>0) {
       if ([viewControllers indexOfObject:viewController] ==5||[viewControllers indexOfObject:viewController] ==7) {
        return NO;
    }
    }
    else
    {
        [Global loginViewController:self noteStr:@"请登录"];
    }
    return YES;
}
-(void)secondLevelCellClick
{
        if (scanHomeVC.timer!=nil) {
            [scanHomeVC.timer invalidate];
            scanHomeVC.timer=nil;
        }
        if (scanHomeVC.captureSession!=nil) {
            
            
            [scanHomeVC.captureSession stopRunning];
            scanHomeVC.captureSession = nil;
        }
        if (scanHomeVC.videoPreviewLayer !=nil) {
            
            
            [scanHomeVC.videoPreviewLayer removeFromSuperlayer];
        }
  
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
